'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var newModel = baseController.getBaseDocFields();
//条码主档
newModel.BarcodeMaster = {
    type: Schema.ObjectId,
    ref: 'BarcodeMaster'
};
//条码
newModel.Barcode = {
    type: String,
    trim: true
};
//入库业务类型，0:生产完工，1: 交接区入库，2：采购收货
newModel.RcvBusinessType = {
    type: Number
};
//业务单据ID
newModel.BusinessDocID = {
    type: String,
    default:'',
    trim: true
};
//批号
newModel.LotNumber = {
    type: String,
    trim: true
};
//物料
newModel.ItemMaster = {
    type: Schema.ObjectId,
    ref: 'ItemMaster'
};
//入库人
newModel.RcvUser = {
    type: Schema.ObjectId,
    ref: 'User'
};
//入库时间
newModel.RcvDateTime = {
    type: Date,
    default: Date.now
};
//入库数量
newModel.RcvQty = {
    type: Number
};
//入库工序
newModel.RcvOperation = {
    type: Schema.ObjectId,
    ref: 'Operation'
};
//对应流水
newModel.BizRecord = {
    type: Schema.ObjectId,
    ref: 'BizRecord'
};
//交接区
newModel.ConnectArea = {
    type: Schema.ObjectId,
    ref: 'ConnectArea'
};
//位置
newModel.Location = {
    type: String,
    default: '',
    trim: true
};
//ERP MO.ID
newModel.ERPID = {
    type: String,
    trim: true
};

var newSchema = new Schema(newModel);
newSchema.index({ItemMaster: 1});
newSchema.index({RcvDateTime: 1});

mongoose.model('RcvRecord', newSchema, 'RcvRecord');
